/**
 * 组织结构员工列表控制器
 */
import $_fn from '~plugins'
import './index.less'
export default ['$scope','$rootScope','$location','$ui','http','$state',function($scope,$rootScope,$location,$ui,http,$state) {
    $scope.$_fn = $_fn
	//四级按钮
	$scope.tabMenu = $_fn.getCurrMenu($location.path())
    console.log($scope.tabMenu)
    $scope.subMenu = $scope.tabMenu.children[0].children
    console.log($scope.subMenu)
	console.log('组织结构员工列表控制器')
	//四级按钮页面跳转方法
	$scope.operation = function (path,item) {
		console.log('111')
        var _path = path.split('@')
        let params = JSON.stringify(item)
        if(_path[0] == 'link'){
            console.log(path)
            $state.go(_path[1], item)
        }
        if(_path[0] == 'alert'){
            $ui.modal({content:"<"+_path[1]+" params="+params+"></"+_path[1]+">"})
        }
   }
	//分页参数
    $scope.page = {
      current:  1
    }
    //获取数据的入参
    $scope.params = {}
    //获取数据的函数
    $scope.getDada = function(page,params){
        params.pageNum = page
        http.post('appLogPageInit.do',params,function (data) {
            var _data = data.data
            $scope.page.pageNum =  $scope.page.current
            $scope.page.pageSize = _data.pageSize
            $scope.page.total = _data.total
            if(data.errcode > 0){
                //列表无数据
                $scope.$apply(function () {
                    $scope.dataList = _data.list

                })
            }else{
                $scope.errorToast(data.errmsg)
            }
        })
    }
    //初始化数据
    $scope.getDada(1,$scope.params)
    //提示错误
    $scope.errorToast = function(text) {
        $ui.toast({text:text,type:'warning',position:'center',appendTo:'.main-content'});
    }
}]
